import request from "@/utils/request";

// 分页
export function pageData(params){
  return request({
    url:'/userRest/page',
    method:'get',
    params
  })
}

export function create(data){
  return request({
    url:'/userRest/create',
    method:'post',
    data
  })
}


export function update(data){
  return request({
    url:'/userRest/update',
    method:'put',
    data
  })
}


export function removeById(id){
  return request({
    url: `/userRest/remove?id=${id}`,
    method: 'delete',
  })
}

export function updateUserGroupRole({ uid,roles,groups }){
  return request({
    url:'/userRest/updateGroupRole',
    method:'post',
    data:{roles,groups,uid}
  })
}


export function loadUserGroupsAndRoles(uid) {
  return request({
    url: `/userRest/rolesAndGroups/${uid}`,
    method: 'get'
  })
}

export function updateSelfInfo(userInfo) {
  return request({
    url: '/userRest/updateSelfInfo',
    data: userInfo,
    method: 'post'
  })
}

export function resetPassword({password}) {
  return request({
    url: '/userRest/resetPassword',
    method: 'post',
    data: {
      password
    }
  })
}
